package com.his.dictitem.service.Imp;

import com.his.dictitem.dao.DictItemPackageunitMapper;
import com.his.dictitem.entity.DictItemMedicine;
import com.his.dictitem.entity.DictItemPackageunit;
import com.his.dictitem.service.DictItemPackageunitService;
import com.his.dictitem.vo.DictItemPackageunitVo;
import com.his.login.entity.DictEmployee;
import com.xiao.common.util.BeanUtil;
import com.xiao.common.util.WorkIdUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

@Service
public class DictItemPackageunitServiceImpl implements DictItemPackageunitService {
    @Autowired
    private DictItemPackageunitMapper dictItemPackageunitMapper;

    @Override
    public void insert(DictEmployee dictEmployee, DictItemPackageunitVo dictItemPackageunitVo) {
        DictItemPackageunit dictItemPackageunit=BeanUtil.copyBean(dictItemPackageunitVo, DictItemPackageunit.class);
        dictItemPackageunit.setId(WorkIdUtil.nextId());
        dictItemPackageunit.setCreaterId(dictEmployee.getEMPID());
        dictItemPackageunit.setCreaterName(dictEmployee.getEMPNAME());
        dictItemPackageunit.setCreateTime(new Date());
        dictItemPackageunitMapper.insert(dictItemPackageunit);
    }

    @Override
    public void updateItemPackageunit(DictEmployee dictEmployee, DictItemPackageunitVo dictItemPackageunitVo) {
        DictItemPackageunit dictItemPackageunit=BeanUtil.copyBean(dictItemPackageunitVo, DictItemPackageunit.class);
        dictItemPackageunit.setUpdaterId(dictEmployee.getEMPID());
        dictItemPackageunit.setUpdaterName(dictEmployee.getEMPNAME());
        dictItemPackageunit.setUpdateTime(new Date());
        dictItemPackageunitMapper.updateByPrimaryKeySelective(dictItemPackageunit);
    }

    @Override
    public DictItemPackageunit selectByType(DictItemPackageunitVo dictItemPackageunitVo) {
        DictItemPackageunit dictItemPackageunit=BeanUtil.copyBean(dictItemPackageunitVo, DictItemPackageunit.class);
        return dictItemPackageunitMapper.selectByType(dictItemPackageunit);
    }
}
